<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>索书号检查</title>
    <meta name="decorator" content="default"/>
    <script src="${ctxStatic}/lodop/LodopFuncs.js" type="text/javascript"></script>
    <script>
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e.altKey && e.keyCode == 83) {
                refreshParentPage();
            }
        };
        function refreshParentPage(){
            window.parent.refresh = true;
            window.parent.window.jBox.close();
        }
    </script>
    <style>
        .field { width: 80px; text-align: right; } td { height: 30px; }
    </style>
</head>
<body>

<sys:message type="warning" content="${message}"/>
<c:if test="${not empty message and message != ''}">
    <a href="${ctx}/book/purchase/gotoSetUpStartBanId">重新设置起始条码号</a>
</c:if>
<script>
    top.$.jBox.tip.mess=undefined;
</script>

<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th>条形码</th>
        <th>索书号</th>
        <th>ISBN</th>
        <th>题名</th>
        <th>著者</th>
        <th>出版社</th>
        <th>出版日期</th>
        <th width="110">操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${stores}" var="store">
        <tr>
            <td>${store.banid}</td>
            <td>${store.classcode}/${store.place}</td>
            <td>${store.isbn}</td>
            <td>${store.bookname}</td>
            <td>${store.author}</td>
            <td>${store.publisher}</td>
            <td>${store.pubdate}</td>
            <td>
                <shiro:hasPermission name="book:store:delete">
                    <a href="javascript:deleteStore('${store.id}')">删除</a>
                </shiro:hasPermission>
                <a href="javascript:printTag('${store.banid}', '${store.place}', '${store.classcode}')">书标打印</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="form-actions">
    <input class="btn btn-primary" type="button" style="margin-left: 40%;" onclick="refreshParentPage()"
           value="关闭页面 Alt+S"/>
</div>
<object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <param name="Border" value="1">
    <param name="Color" value="white">
    <embed id="LODOP_EM" TYPE="application/x-print-lodop" width=0 height=0 border=0 Color="white"
           PLUGINSPAGE="install_lodop.exe">
</object>
<script type="text/javascript">
    function deleteStore(storeId){
        $.ajax({
            type: "POST",
            url: "${ctx}/book/store/deleteByStoreId",
            data: {storeId: storeId},
            dataType: "json",
            success: function (data) {
                if (data.code == "0001") {
                    window.parent.refresh = true;
                    top.$.jBox.info(data.msg, '提示', {
                        closed: function () {
                            location.reload();
                        }
                    });
                    top.$('.jbox-body .jbox-icon').css('top', '55px');

                } else {
                    alertx("删除书籍典藏信息失败");
                }
            }
        });
    }
    /**
     *  打印预览
     */
    //声明为全局变量
    var LODOP;
    function printTag(banid, place, classcode) {
        LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM'));
        LODOP.PRINT_INIT("打印");
        LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
        /*// 打印条形码
        LODOP.ADD_PRINT_BARCODE(25, 34, 159, 50, "code39", banid);

        var school = "<div style='background-color:#ffffff;font-size: 13px;text-align: center;'>" +
                "<div style='height:20px;'>" + "图书馆" + "</div>" +
                "</div>";
        LODOP.ADD_PRINT_HTM(75, 34, 159, 25, school);*/

        // 打印 索书号和分类
        var bar = "<div style='background-color:#ffffff;font-size: 18px;text-align: center;'>" +
                "<div style='height:25px;'>" + classcode + "</div>" +
                "<div style='height:25px;'>" + place + "</div>" +
                "<div style='height:16px;font-size: 13px;'>" + banid + "</div>" +
                "</div>";
        LODOP.ADD_PRINT_HTM(25, 34, 159, 70, bar);
        LODOP.PRINT_DESIGN();
        LODOP.SHOW_CHART();
    }
</script>
</body>
</html>